home *** CD-ROM | disk | FTP | other *** search
/ Micom Basic 1995 October / CD [BM9510].bin / programs / lotus / lotus001.dsk / MACROS / BUILDER.SAM (.txt) < prev    next >
Encoding:
Ami Pro/Word Pro document  |  1994-08-11  |  14.9 KB  |  422 lines

  1. [ver]
  2. [sty]
  3.     jmacro.sty
  4. [files]
  5. [charset]
  6.     SHIFTJIS (Windows)
  7. [revisions]
  8. [prn]
  9.     QMS-PS 810
  10. [port]
  11.     LPT1:
  12. [lang]
  13. [desc]
  14.     BUILD.SMM 
  15.     752802295
  16.     736633139
  17. [fopts]
  18. [lnopts]
  19.     Body Text
  20. [docopts]
  21. [GramStyle]
  22. [lay]
  23.     Standard
  24.     [rght]
  25.         15840
  26.         12240
  27.         576
  28.         720
  29.         1080
  30.         576
  31.         576
  32.         11664
  33.         720
  34.         1440
  35.         2160
  36.         2880
  37.         3600
  38.         4320
  39.         5040
  40.         5760
  41.         6480
  42.         7200
  43.         7920
  44.         8640
  45.     [hrght]
  46.     [lyfrm]
  47.         11200
  48.         12240
  49.         1080
  50.         1 0 0 0 0 0 0
  51.     [frmlay]
  52.         1080
  53.         12240
  54.         1440
  55.         792
  56.         1440
  57.         1440
  58.         10800
  59.         4680
  60.         9360
  61.     [txt]
  62.     [frght]
  63.     [lyfrm]
  64.         13248
  65.         15120
  66.         12240
  67.         15840
  68.         1 0 0 0 0 0 0
  69.     [frmlay]
  70.         15840
  71.         12240
  72.         1440
  73.         648
  74.         15192
  75.         1440
  76.         1440
  77.         10800
  78.         4680
  79.         9360
  80.     [txt]
  81. [elay]
  82.     58 0 15 0 0 0 0 65535 65535 Standard    65535 0 0    0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0
  83.     116 0 59 0 0 0 0 65535 65535 Standard    65535 0 0    0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0
  84.     170 0 5 512 0 0 0 65535 65535 Standard    65535 0 0    0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0
  85.     228 0 32 0 0 1 0 65535 65535 Standard    65535 0 0    0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0
  86.     285 0 11 0 0 1 0 65535 65535 Standard    65535 0 0    0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0
  87.     331 0 10 1025 0 0 0 65535 65535 Standard    65535 0 0    0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0
  88. [edoc]
  89. <:#240,11088>
  90. <:#240,11088>
  91. <:#240,11088>
  92. <:#240,11088>
  93. <:#240,11088>' Declare functions
  94. <:#240,11088>Declare    FontDlg(Action, Hdlg, id)
  95. <:#240,11088>Declare    CellEngine(action,Form)
  96. <:#240,11088>Declare    StrPath(Filename)
  97. <:#240,11088>Declare    SizeBox(Hdlg, NumberEditControls)
  98. <:#240,11088>Declare GetFormats(Action)
  99. <:#240,11088>
  100. <:#240,11088>' WinApi defines
  101. <:#240,11088>Define SetWindowText(hwnd, text)    DllCall("user,SetWindowText,IHC", %1, %2)
  102. <:#240,11088>Define MoveWindow() DllCall("User,MoveWindow,HHHHHHA",%1,%2,%3,%4,%5,%6)
  103. <:#240,11088>DEFINE GetWindowRect()    DllCall("user,GetWindowRect,HHN",%1,%2)
  104. <:#240,11088>Define ShowWindow(hWnd, stuff) DllCall("user,ShowWindow,HHH", %1, %2)
  105. <:#240,11088>Define getsystemmetrics() dllcall("user,getsystemmetrics,HH", %1)
  106. <:#240,11088>
  107. <:#240,11088>
  108. <:#240,11088>Define    GetPrefix()    GetGlobalVar$("Prefix")
  109. <:#240,11088>Define    GetSuffix()    GetGlobalVar$("Suffix")
  110. <:#240,11088>
  111. <:#240,11088>
  112. @<:#240,11088>Function Main()
  113. <:#240,11088>DefStr hInstance;
  114. <:#240,11088>
  115. <:#240,11088>
  116. <:#240,11088>Mac = GetRunningMacroFile$()
  117. <:#240,11088>MacPath = StrPath(Mac)
  118. <:#240,11088>FontDlg(1,0,0)
  119. <:#240,11088>CellEngine(1,0)
  120. <:#240,11088>GetFormats(1)
  121. <:#240,11088>FillEdit(1000, HelpText)
  122. <:#240,11088>SetDlgCallBack(0,"{Mac}!InitDlg")
  123. <:#240,11088>For Id = 8001 to 8009
  124. <:#240,11088>    SetDlgCallBack(Id, "{Mac}!DataChange")
  125. <:#240,11088>Next
  126. <:#240,11088>
  127. <:#240,11088>FillEdit(1001, Value1Text)
  128. <:#240,11088>FillEdit(1002, Value2Text)
  129. <:#240,11088>FillEdit(1003, Value3Text)
  130. <:#240,11088>FillEdit(1004, Value4Text)
  131. <:#240,11088>FillEdit(1005, Value5Text)
  132. <:#240,11088>FillEdit(1006, Value6Text)
  133. <:#240,11088>FillEdit(1007, Value7Text)
  134. <:#240,11088>FillEdit(1008, Value8Text)
  135. <:#240,11088>FillEdit(1009, Value9Text)
  136. <:#240,11088>
  137. <:#240,11088>
  138. <:#240,11088>Box = DialogBox(".","Deprec")
  139. <:#240,11088>If Box = 3
  140. <:#240,11088>    ' box closed with the copy button
  141. <:#240,11088>    Answer = GetDialogField$(8010)
  142. <:#240,11088>    ClipBoardWrite(Answer,1)
  143. <:#240,11088>Endif
  144. <:#240,11088>
  145. <:#240,11088>FontDlg(4,0,0)
  146. <:#240,11088>CellEngine(0,0)
  147. <:#240,11088>GetFormats(0)
  148. <:#240,11088>End function
  149. <:#240,11088>
  150. <:#240,11088>
  151. @<:#240,11088>Function DataChange(Hdlg, id, value)
  152. <:#240,11088>IgnoreKeyBoard(2)
  153. <:#240,11088>DefStr Allowance;
  154. <:#240,11088>Value1 = GetDlgItemText(hDlg, 8001) * 1
  155. <:#240,11088>Value2 = GetDlgItemText(hDlg, 8002) * 1
  156. <:#240,11088>value3 = GetDlgItemText(hDlg, 8003) * 1
  157. <:#240,11088>value4 = GetDlgItemText(hDlg, 8004) * 1
  158. <:#240,11088>value5 = GetDlgItemText(hDlg, 8005) * 1
  159. <:#240,11088>value6 = GetDlgItemText(hdlg, 8006) * 1
  160. <:#240,11088>value7 = GetDlgItemText(hdlg, 8007) * 1
  161. <:#240,11088>value8 = GetDlgItemText(hdlg, 8008) * 1
  162. <:#240,11088>value9 = GetDlgItemText(hdlg, 8009) * 1
  163. <:#240,11088>Answer = CellEngine(3,Formula)      
  164. <:#240,11088>Answer = FormatNum$("","",2,Answer )
  165. <:#240,11088>SetDlgItemText(hDlg, 8010, Answer)
  166. <:#240,11088>End Function
  167. <:#240,11088>
  168. @<:#240,11088>Function InitDlg(hDlg, id, value)
  169. <:#240,11088>' use the fontdlg function to display the following control with a small font
  170. <:#240,11088>HourGlass(on)
  171. <:#240,11088>SetWindowText(Hdlg, DialogTitle)
  172. <:#240,11088>FontDlg(3, Hdlg, 1000)
  173. <:#240,11088>For Id = 1 to 9
  174. <:#240,11088>    FontDlg(3, Hdlg, id + 1000)
  175. <:#240,11088>    FontDlg(3, Hdlg, id + 8000)
  176. <:#240,11088>    If Id <;> NumberItems
  177. <:#240,11088>        ShowWindow(GetDlgItem(Hdlg, id + 1000), 0)
  178. <:#240,11088>        ShowWindow(GetDlgItem(Hdlg, id + 8000), 0)
  179. <:#240,11088>    Endif
  180. <:#240,11088>Next
  181. <:#240,11088>FontDlg(3, Hdlg, 8010)
  182. <:#240,11088>FontDlg(3, Hdlg, 8011)
  183. 'SizeBox(Hdlg, NumberItems)
  184. <:#240,11088>HourGlass(off)
  185. <:#240,11088>
  186. <:#240,11088>End Function
  187. <:#240,11088>
  188. <:#240,11088>
  189. @<:#240,11088>Function SizeBox(Hdlg, NumberEditControls)
  190. <:#240,11088>Define    Repaint 1
  191. <:#240,11088>Dim Rect(4)
  192. <:#240,11088>Stat = GetSystemMetrics(4)
  193. <:#240,11088>GetWindowRect(Hdlg, &Rect)
  194. <:#240,11088>DeltaX = Rect(3) - Rect(1);
  195. <:#240,11088>NumberIncrease = (NumberEditControls - 3);    
  196. <:#240,11088>If NumberIncrease <<0
  197. <:#240,11088>    NumberIncrease = 0
  198. <:#240,11088>Endif
  199. <:#240,11088>If Stat = 20
  200. <:#240,11088>    DeltaY = (20 * NumberIncrease) + 140;
  201. <:#240,11088>Else
  202. <:#240,11088>    DeltaY = (26 * NumberIncrease) + 190;
  203. <:#240,11088>Endif
  204. <:#240,11088>MoveWindow(Hdlg, Rect(1), Rect(2), DeltaX, DeltaY, Repaint)
  205. <:#240,11088>End Function
  206. <:#240,11088>
  207. <:#240,11088>
  208. @<:#240,11088>Function GetFormats(Action)
  209. <:#240,11088>iCurrency = GetProfileString$("Intl","iCurrency","Win.ini")
  210. <:#240,11088>currency = GetProfileString$("Intl","sCurrency","Win.ini")
  211. <:#240,11088>AllocGlobalVar("Prefix",1)
  212. <:#240,11088>AllocGlobalVar("Suffix",1)
  213. <:#240,11088>
  214. <:#240,11088>Switch Action
  215. <:#240,11088>    Case 1     ' turn this on
  216. <:#240,11088>        Switch iCurrency
  217. <:#240,11088>            Case 0
  218. <:#240,11088>                Prefix = Currency
  219. <:#240,11088>                Suffix = ""
  220. <:#240,11088>            Case 1
  221. <:#240,11088>                Prefix = ""
  222. <:#240,11088>                Suffix = Currency
  223. <:#240,11088>            Case 2
  224. <:#240,11088>                Prefix = StrCat$(Currency," ")
  225. <:#240,11088>                Suffix = ""
  226. <:#240,11088>            Case 3
  227. <:#240,11088>                Prefix = ""
  228. <:#240,11088>                Suffix = StrCat$(" ",Currency)
  229. <:#240,11088>        endSwitch
  230. <:#240,11088>        SetGlobalVar("Suffix",Suffix)
  231. <:#240,11088>        SetGlobalVar("Prefix",Prefix)
  232. <:#240,11088>
  233. <:#240,11088>    Case 0    ' free globals
  234. <:#240,11088>        FreeGlobalVar("Suffix")
  235. <:#240,11088>        FreeGlobalVar("Prefix")
  236. <:#240,11088>        
  237. <:#240,11088>EndSwitch
  238. <:#240,11088>End Function
  239. <:#240,11088>
  240. <:#240,11088>
  241. <:#240,11088>
  242. @<:#240,11088>function strpath(filename)
  243. <:#240,11088>defstr char;
  244. <:#240,11088>Length = len(FileName)
  245. <:#240,11088>WHILE "\" != Assign(&Char, MID$(FileName, Length, 1))
  246. <:#240,11088>    Length = Length - 1
  247. <:#240,11088>WEND
  248. <:#240,11088>InFileName = Right$(FileName, (len(FileName) - Length))
  249. <:#240,11088>InDir = Left$(FileName, Length - 1) 
  250. <:#240,11088>if right$(indir, 1) <<<;> "\"
  251. <:#240,11088>    indir = strcat$(indir, "\")
  252. <:#240,11088>endif
  253. <:#240,11088>return indir
  254. <:#240,11088>end function
  255. <:#240,11088>
  256. <:#240,11088>
  257. <:#240,11088>
  258. <:p<* >>
  259. @<:#240,11088>Function CellEngine(Action,Form)
  260. <:#240,11088>'Available Actions
  261. <:#240,11088>'    1         Start the engine and allocate globalvar
  262. <:#240,11088>'    2        Return the handle to the instance of the sheet
  263. <:#240,11088>'    3        Pass the formula as the second param
  264. <:#240,11088>'    0        Shut everything down
  265. <:#240,11088>'    Default    Expect a formula and return an answer
  266. <:#240,11088>
  267. <:#240,11088>' these defines may be useful at the beginning of your macro
  268. <:#240,11088>Define StartEngine    1
  269. <:#240,11088>Define GetInstance    2
  270. <:#240,11088>Define CloseEngine    0
  271. <:#240,11088>
  272. <:#240,11088>Define    CECREATEINSTANCE(LPHANDLE)    DllCall("LTSCE01.DLL,CECREATEINSTANCE,HO",%1)
  273. <:#240,11088>Define    CEDESTROYINSTANCE(HANDLE)    DllCall("LTSCE01.DLL,CEDESTROYINSTANCE,HH",%1)
  274. <:#240,11088>Define    CECALCNOW(HINSTANCE, lpFormula, lpOutPut)    DllCall("LTSCE01.DLL,CECALCNOW,HHCC",%1,%2,%3)
  275. <:#240,11088>
  276. <:#240,11088>DefStr hInstance, Answer, Var;
  277. <:#240,11088>Mac = GetRunningMacroFile$()
  278. <:#240,11088>GlobalInstance = StrCat$(Mac,"hIstance")
  279. <:#240,11088>AmiDir = GetAmiDirectory$()
  280. <:#240,11088>
  281. <:#240,11088>Switch Action
  282. <:#240,11088>    Case 1
  283. <:#240,11088>        ' start the engine
  284. <:#240,11088>        LibId = DLLLoadLib("{AmiDir}LTSCE01.DLL","CECreateInstance","HO")
  285. <:#240,11088>        If LibId = 0
  286. <:#240,11088>            Message("LTSCE01.DLL not found.  Copy the dll to your Ami Pro Directory.")    
  287. <:#240,11088>            Return -1;
  288. <:#240,11088>        Endif
  289. <:#240,11088>        RetVal = CECREATEINSTANCE(&hInstance)
  290. <:#240,11088>        AllocGlobalVar("{GlobalInstance}",1)
  291. <:#240,11088>        AllocGlobalVar("{Mac}LibId",1)
  292. <:#240,11088>        SetGlobalVar("{Mac}Libid",LibId)
  293. <:#240,11088>        SetGlobalVar("{GlobalInstance}",hInstance)
  294. <:#240,11088>        Return hInstance;
  295. <:#240,11088>        Break;
  296. <:#240,11088>
  297. <:#240,11088>    Case 2
  298. <:#240,11088>        ' return the handle to the instance of the sheet
  299. <:#240,11088>        AllocGlobalVar("{GlobalInstance}",1)
  300. <:#240,11088>        hInstance = GetGlobalVar$("{GlobalInstance}")
  301. <:#240,11088>        Return hInstance;
  302. <:#240,11088>        Break;
  303. <:#240,11088>
  304. <:#240,11088>    Case 3
  305. <:#240,11088>        ' Calculate the formula and return the answer
  306. <:#240,11088>        AllocGlobalVar("{GlobalInstance}",1)
  307. <:#240,11088>        hInstance = GetGlobalVar$("{GlobalInstance}")
  308. <:#240,11088>        CECalcNow(hInstance,"{Form}",&Answer)
  309. <:#240,11088>        Return Answer;
  310. <:#240,11088>        Break;
  311. <:#240,11088>    
  312. <:#240,11088>
  313. <:#240,11088>    Case 0
  314. <:#240,11088>        ' destroy the instance of the sheet and free the global var and libid
  315. <:#240,11088>        AllocGlobalVar("{GlobalInstance}",1)
  316. <:#240,11088>        AllocGlobalVar("{Mac}LibId",1)
  317. <:#240,11088>        hInstance = GetGlobalVar$("{GlobalInstance}")
  318. <:#240,11088>        LibId = GetGlobalVar$("{Mac}LibId")
  319. <:#240,11088>        If hInstance
  320. <:#240,11088>            CEDestroyInstance(hInstance)
  321. <:#240,11088>            DllFreeLib(Libid)
  322. <:#240,11088>        Endif
  323. <:#240,11088>        FreeGlobalVar("{GlobalInstance}")
  324. <:#240,11088>        FreeGlobalVar("{Mac}LibId")
  325. <:#240,11088>        Break;
  326. <:#240,11088>
  327. <:#240,11088>    Default
  328. <:#240,11088>EndSwitch
  329. <:#240,11088>End Function
  330. <:#240,11088>
  331. <:#240,11088>
  332. <:#240,11088>
  333. <:#240,11088>
  334. <:#240,11088>
  335. @<:#240,11088>Function FontDlg(Action, Hdlg, id)
  336. <:#240,11088>' 1    Create a font and allocvar
  337. <:#240,11088>' 2    Return the handle of the create font 
  338. <:#240,11088>' 3    Set the id specified to the font
  339. <:#240,11088>' 4    Freeglobalvar and delete created object
  340. <:#240,11088>
  341. <:#480,11088>define    CreateFontDLG()        DllCall("gdi,CreateFont,HHHHHHHHHHHHHHC", %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14)
  342. <:#240,11088>define    DeleteObjectDLG(handle)    DllCall("gdi,DeleteObject,HH", %1)
  343. <:#240,11088>define    SendMessageDLG(hwnd, msg, wpara, lparm)    DllCall("user,SendMessage,HHHHJ", %1, %2, %3, %4)
  344. <:#240,11088>
  345. <:#240,11088>Mac = GetRunningMacroFile$()
  346. <:#240,11088>
  347. <:#240,11088>Switch Action
  348. <:#240,11088>    Case 1    ' Create the font and store it
  349. <:#240,11088>        Font = CreateFontDLG(13, 0, 0, 0, 400, 0, 0, 0, 128, 0, 0, 0, 32, "System") 'Helv
  350. <:#240,11088>        AllocGlobalVar("{Mac}FontHandle",1)
  351. <:#240,11088>        If Font
  352. <:#240,11088>            SetGlobalVar("{Mac}FontHandle",Font)
  353. <:#240,11088>            Return Font
  354. <:#240,11088>        Else
  355. <:#240,11088>            Return 0;    ' no font
  356. <:#240,11088>        Endif
  357. <:#240,11088>        Break;
  358. <:#240,11088>    Case 2    ' Return the handle to the font
  359. <:#240,11088>        Handle = GetGlobalVar$("{Mac}FontHandle")
  360. <:#240,11088>        If Handle 
  361. <:#240,11088>            Return Handle
  362. <:#240,11088>        Else
  363. <:#240,11088>            Return 0
  364. <:#240,11088>        Endif
  365. <:#240,11088>
  366. <:#240,11088>    Case 3    ' Set the id to the font
  367. <:#240,11088>        Handle = GetGlobalVar$("{Mac}FontHandle")
  368. <:#240,11088>        If Handle 
  369. <:#240,11088>            IdControl = GetDlgITem(Hdlg, id)
  370. <:#240,11088>            SendMessageDlg(idControl, 0x30, Handle, 0)
  371. <:#240,11088>            Return 1
  372. <:#240,11088>        Else
  373. <:#240,11088>            Return 0
  374. <:#240,11088>        Endif
  375. <:#240,11088>        Break;        
  376. <:#240,11088>        
  377. <:#240,11088>    Case 4    ' Delete the font and clear the var
  378. <:#240,11088>        Handle = GetGlobalVar$("{Mac}FontHandle")
  379. <:#240,11088>        If Handle
  380. <:#240,11088>            DeleteObjectDLG(Handle)
  381. <:#240,11088>            Stat = 1    
  382. <:#240,11088>        Else
  383. <:#240,11088>            Stat = 0
  384. <:#240,11088>        Endif
  385. <:#240,11088>        FreeGlobalVar("{Mac}FontHandle")
  386. <:#240,11088>        Return Stat        
  387. <:#240,11088>    Default
  388. <:#240,11088>        Message("Fontdlg received an invalid parameter {Action}")
  389. <:#240,11088>EndSwitch    
  390. <:#240,11088>
  391. <:#240,11088>End Function
  392. <:#240,11088>
  393. <:#240,11088>
  394. <:#240,11088>
  395. <:#240,11088>
  396. <:#240,11088>
  397. <:#240,11088>
  398. <:#240,11088>
  399. <:#240,11088>DIALOG    Deprec
  400. <:#240,11088>-2134376448    17    79    49    158    114    ""    ""    "Dialog Title"
  401. <:#240,11088>FONT    8    "System"
  402. <:#240,11088>60    28    33    12    8001    1350631552    "edit"    ""    0 
  403. 60    42    33    12    8002    1350631552    "edit"    ""    0 
  404. <:#240,11088>60    56    33    12    8003    1350631552    "edit"    ""    0 
  405. 60    70    33    12    8004    1350631552    "edit"    ""    0 
  406. <:#240,11088>60    84    33    12    8005    1350631552    "edit"    ""    0 
  407. 60    98    33    12    8006    1350631552    "edit"    ""    0 
  408. <:#240,11088>114    2    40    13    1    1342373889    "button"    "OK"    0 
  409. <:#240,11088>114    18    40    13    3    1342373888    "button"    "
  410. <:#240,11088>106    52    38    8    8010    1342177282    "static"    ""    0 
  411. <:#240,11088>98    39    57    29    20    1342177287    "button"    "
  412. <:#240,11088>4    1    103    24    1000    1342177280    "static"    ""    0 
  413. <:#240,11088>4    29    56    8    1001    1342177280    "static"    "value1text"    0 
  414. 4    43    56    8    1002    1342177280    "static"    "value2text"    0 
  415. <:#240,11088>4    57    56    8    1003    1342177280    "static"    "value3text"    0 
  416. 4    71    56    8    1004    1342177280    "static"    "value4text"    0 
  417. <:#240,11088>4    85    56    8    1005    1342177280    "static"    "value5text"    0 
  418. 4    99    56    8    1006    1342177280    "static"    "value6text"    0 
  419. <:#240,11088>END DIALOG
  420. [Embedded]
  421. 00015248
  422.